@extends('layout.wechat_frame')

@section('main')
    <header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h1 class="mui-title">投标报价-不参与报价</h1>
    </header>

    <div class="mui-content">

        <form method="post" action="{{ route('bidQuote.bqDetail.refuseOffer', ['demand' => $demand->id])}}">

            {!! csrf_field() !!}

        <ul class="mui-table-view mui-table-view-striped mui-table-view-condensed">
            <li class="mui-table-view-cell">
                @if(!empty($offer) and !is_null($offer->reason))

                    <div >
                        <h5 class="mui-ellipsis"><span class="ips-span-first">不参与报价理由</span>
                            <span>{{ $offer->reason }}</span>
                        </h5>
                    </div>
                @else
                    <div >
                        <h5 class="mui-ellipsis"><span class="ips-span-first">不参与报价理由</span>
                            <span id='showUserPicker' class="ips-text-blue">选择</span>
                            <input type="text" id="pickerValue" name="reason" value="" hidden>
                        </h5>

                        <br />
                        <h5 class="mui-ellipsis" id="other_text" style="display: none;" ><span class="ips-span-first">请填写其他理由</span>
                            <span class="ips-span-input" style="width:200px">
                            <input type="text"  name="other" class="ips-inputtext"  placeholder=""></span>
                        </h5>
                    </div>
                 @endif
            </li>
        </ul>

            @if(empty($offer))
                <div class="mui-content-padded ips-detail-page-bottom">
                    <div class="mui-button-row">
                        <button type="submit" id="doRefuseButton" class="mui-btn mui-btn-danger" >提交不参与报价理由</button>
                    </div>
                </div>
            @endif
        </form>
    </div>


@section('js')

    <script type="text/javascript">
        // 到货选择
        (function($, doc) {
            $.init();
            $.ready(function() {
                //普通示例
                var userPicker = new $.PopPicker();
                userPicker.setData([{
                    value: '无货可供',
                    text: '无货可供'
                },  {
                    value: '报价范围受限',
                    text: '报价范围受限'
                },  {
                    value: '交货期受限',
                    text: '交货期受限'
                },  {
                    value: '款期过长',
                    text: '款期过长'
                },  {
                    value: '质量标准无法满足',
                    text: '质量标准无法满足'
                },  {
                    value: '不接受此计重方式',
                    text: '不接受此计重方式'
                },  {
                    value: '交货地点及方式受限',
                    text: '交货地点及方式受限'
                },  {
                    value: '包装达不到要求',
                    text: '包装达不到要求'
                },  {
                    value: '不接受此分配方案',
                    text: '不接受此分配方案'
                },  {
                    value: '其他',
                    text: '其他'
                }]);
                var showUserPickerButton = doc.getElementById('showUserPicker');
                var userResult = doc.getElementById('showUserPicker');
                var pickerValue = doc.getElementById('pickerValue');
                var otherText = doc.getElementById('other_text');
                showUserPickerButton.addEventListener('tap', function(event) {
                    userPicker.show(function(items) {
                        userResult.innerText = items[0].text;
                        pickerValue.value = items[0].value;

                        if(items[0].text == "其他"){

                            otherText.style = "display: block;";
                        } else {
                            otherText.style = "display: none;";
                        }

                        //返回 false 可以阻止选择框的关闭
                        //return false;
                    });
                }, false);
            });
        })(mui, document);

    </script>

@stop